//
//  Dictionary+Extension.swift
//  MCComponentExtension
//
//  Created by 满聪 on 2019/9/9.
//

import Foundation


extension Dictionary {
    
    /// 字段转json字符串
    public func mc_toJSONString() -> String {
        
        if (!JSONSerialization.isValidJSONObject(self)) {
            print("无法解析出JSONString")
            return ""
        }
        let data : NSData! = try? JSONSerialization.data(withJSONObject: self, options: []) as NSData?
        if let JSONString = NSString(data:data as Data,encoding: String.Encoding.utf8.rawValue) {
            return JSONString as String
        } else {
            return ""
        }
    }
}
